home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / PROGRAMR / OLE2BOOK.ZIP / CHAP05.ZIP / CHAP05 / PATRON / PAGES.H < prev    next >
C/C++ Source or Header  |  1993-06-07  |  5KB  |  188 lines

  1. /*
  2.  * PAGES.H
  3.  * Modifications for Chapter 5
  4.  *
  5.  * Definitions and function prototypes for the Pages window control.
  6.  *
  7.  * Copyright (c)1993 Microsoft Corporation, All Rights Reserved
  8.  *
  9.  * Kraig Brockschmidt, Software Design Engineer
  10.  * Microsoft Systems Developer Relations
  11.  *
  12.  * Internet  :  kraigb@microsoft.com
  13.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  14.  */
  15.  
  16.  
  17. #ifndef _PAGES_H_
  18. #define _PAGES_H_
  19.  
  20. //Versioning.
  21. #define VERSIONMAJOR                2
  22. #define VERSIONMINOR                0
  23. #define VERSIONCURRENT              0x00020000
  24.  
  25. //Classname
  26. #define SZCLASSPAGES                "pages"
  27.  
  28. #define HIMETRIC_PER_INCH           2540
  29. #define LOMETRIC_PER_INCH           254
  30. #define LOMETRIC_BORDER             60          //Border around page
  31.  
  32.  
  33. //Window extra bytes and offsets
  34. #define CBPAGESWNDEXTRA             (sizeof(LONG))
  35. #define PAGEWL_STRUCTURE            0
  36.  
  37.  
  38.  
  39.  
  40. /*
  41.  * Page class describing an individual page and what things it contains,
  42.  * managing an IStorage for us.
  43.  *
  44.  * A DWORD is used to identify this page as the name of the storage
  45.  * is the string form of this ID.  If we added a page every second,
  46.  * it would take 136 years to overrun this counter, so we can
  47.  * get away with saving it persistently.  I hope this software is
  48.  * obsolete by then.
  49.  */
  50.  
  51. class __far CPage
  52.     {
  53.     private:
  54.         DWORD       m_dwID;             //Persistent DWORD identifier
  55.         //CHAPTER5MOD
  56.         LPSTORAGE   m_pIStorage;        //Sub-storage for this page.
  57.         //End CHAPTER5MOD
  58.  
  59.     public:
  60.         CPage(DWORD);
  61.         ~CPage(void);
  62.  
  63.         DWORD   GetID(void);
  64.         //CHAPTER5MOD
  65.         BOOL    FOpen(LPSTORAGE);
  66.         void    Close(BOOL);
  67.         BOOL    Update(void);
  68.         void    Destroy(LPSTORAGE);
  69.         //End CHAPTER5MOD
  70.     };
  71.  
  72. typedef CPage FAR * LPPAGE;
  73.  
  74.  
  75.  
  76. //CHAPTER5MOD
  77.  
  78. /*
  79.  * Structures to save with the document describing the device
  80.  * configuration and pages that we have.  This is followed by
  81.  * a list of DWORD IDs for the individual pages.
  82.  */
  83.  
  84. typedef struct __far tagDEVICECONFIG
  85.     {
  86.     DEVMODE     dm;
  87.     char        szDriver[CCHDEVICENAME];
  88.     char        szDevice[CCHDEVICENAME];
  89.     char        szPort[CCHDEVICENAME];
  90.     } DEVICECONFIG, FAR * LPDEVICECONFIG;
  91.  
  92. typedef struct __far tagPAGELIST
  93.     {
  94.     DWORD       cPages;
  95.     DWORD       iPageCur;
  96.     DWORD       dwIDNext;
  97.     } PAGELIST, FAR *LPPAGELIST;
  98.  
  99. //End CHAPTER5MOD
  100.  
  101.  
  102. //PAGEWIN.CPP
  103. LRESULT __export FAR PASCAL PagesWndProc(HWND, UINT, WPARAM, LPARAM);
  104. BOOL    __export FAR PASCAL AbortProc(HDC, int);
  105. BOOL    __export FAR PASCAL PrintDlgProc(HWND, UINT, WPARAM, LPARAM);
  106.  
  107.  
  108.  
  109. class __far CPages : public CWindow
  110.     {
  111.     friend LRESULT __export FAR PASCAL PagesWndProc(HWND, UINT, WPARAM, LPARAM);
  112.     friend BOOL    __export FAR PASCAL PrintDlgProc(HWND, UINT, WPARAM, LPARAM);
  113.  
  114.     private:
  115.         UINT        m_iPageCur;             //Current page we're viewing
  116.         UINT        m_cPages;               //Number of pages
  117.  
  118.         HWND        m_hWndPageList;         //Listbox that manages out page list
  119.         HFONT       m_hFont;                //Page font.
  120.         BOOL        m_fSystemFont;          //Is m_hFont system object?
  121.  
  122.         UINT        m_cx;                   //Current page size in LOMETRIC
  123.         UINT        m_cy;
  124.  
  125.         UINT        m_xMarginLeft;          //Unusable page margins, LOMETRIC
  126.         UINT        m_xMarginRight;
  127.         UINT        m_yMarginTop;
  128.         UINT        m_yMarginBottom;
  129.  
  130.         UINT        m_xPos;                 //Current viewport scroll position.
  131.         UINT        m_yPos;                 //both in *PIXELS*
  132.  
  133.         DWORD       m_dwIDNext;             //Next ID for a page.
  134.  
  135.         //CHAPTER5MOD
  136.         LPSTORAGE   m_pIStorage;            //Root storage of document.
  137.  
  138.         //m_hDevMode, m_szDriver, m_szDevice, m_szPort removed
  139.         //End CHAPTER5MOD
  140.  
  141.     private:
  142.         void      Draw(HDC, BOOL, BOOL);
  143.         void      UpdateScrollRanges(void);
  144.         void      RectConvertMappings(LPRECT, HDC, BOOL);
  145.         BOOL      ConfigureForDevice(void);
  146.         BOOL      FPageGet(UINT, LPPAGE FAR *, BOOL);
  147.         BOOL      FPageAdd(UINT, DWORD, BOOL);
  148.  
  149.     public:
  150.         CPages(HINSTANCE);
  151.         ~CPages(void);
  152.  
  153.         BOOL      FInit(HWND, LPRECT, DWORD, UINT, LPVOID);
  154.  
  155.         //CHAPTER5MOD
  156.         BOOL      FIStorageSet(LPSTORAGE, BOOL, BOOL); //Was ::New previously
  157.         BOOL      FIStorageUpdate(BOOL);
  158.         //End CHAPTER5MOD
  159.  
  160.         BOOL      Print(HDC, LPSTR, DWORD, UINT, UINT, UINT);
  161.  
  162.         void      RectGet(LPRECT);
  163.         void      RectSet(LPRECT, BOOL);
  164.         void      SizeGet(LPRECT);
  165.         void      SizeSet(LPRECT, BOOL);
  166.  
  167.         UINT      PageInsert(UINT);
  168.         UINT      PageDelete(UINT);
  169.         UINT      CurPageGet(void);
  170.         UINT      CurPageSet(UINT);
  171.         UINT      NumPagesGet(void);
  172.  
  173.         BOOL      DevModeSet(HGLOBAL, HGLOBAL);
  174.         HGLOBAL   DevModeGet(void);
  175.     };
  176.  
  177. typedef CPages FAR * LPCPages;
  178.  
  179.  
  180. //CHAPTER5MOD
  181. //Fixed names of streams in the Pages IStorage
  182. #define SZSTREAMPAGELIST        "Page List"
  183. #define SZSTREAMDEVICECONFIG    "Device Configuration"
  184. //End CHAPTER5MOD
  185.  
  186.  
  187. #endif  //_PAGES_H_
  188.